# Maintainer: Leonidas Spyropoulos <artafinde@archlinux.org>

pkgname=gitlab-exporter
pkgver=0.3.0
pkgrel=2
pkgdesc='A Gitlab prometheus metric exporter'
arch=('loong64' 'x86_64')
url='https://gitlab.archlinux.org/artafinde/gitlab-exporter'
license=('MIT')
depends=('gcc-libs' 'openssl')
makedepends=('cargo' 'git')
source=("git+$url.git?signed#tag=v$pkgver")
b2sums=('SKIP')
validpgpkeys=(
  'B4B759625D4633430B74877059E43E106B247368' # Leonidas Spyropoulos <artafinde@archlinux.org>
  ) 

prepare() {
  cd "${pkgname}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "${pkgname}"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  CFLAGS+=' -ffat-lto-objects'
  cargo build --release --frozen
}

check() {
  cd "${pkgname}"
  export RUSTUP_TOOLCHAIN=stable
  CFLAGS+=' -ffat-lto-objects'
  cargo test --frozen -- --test-threads 1
}

package() {
  cd "${pkgname}"
  install -Dm755 target/release/${pkgname} -t "${pkgdir}"/usr/bin
  install -Dm644 README.md -t "${pkgdir}"/usr/share/doc/${pkgname}
  install -Dm644 LICENSE -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
